//
//  NSString+Common.m
//  GeniusHelp_OC
//
//  Created by 8b410-2 on 16/10/23.
//  Copyright © 2016年 8b410-2. All rights reserved.
//

#import "NSString+Common.h"
#import <CommonCrypto/CommonDigest.h>
@implementation NSString (Common)
- (NSString *)toMD5:(NSString *)string {
    const char* original_str=[string UTF8String];
    unsigned char digist[CC_MD5_DIGEST_LENGTH]; //CC_MD5_DIGEST_LENGTH = 16
    CC_MD5(original_str, (uint)strlen(original_str), digist);
    NSMutableString* outPutStr = [NSMutableString stringWithCapacity:10];
    for(int  i =0; i<CC_MD5_DIGEST_LENGTH;i++){
        [outPutStr appendFormat:@"%02x", digist[i]];//小写x表示输出的是小写MD5，大写X表示输出的是大写MD5
    }
    return [outPutStr lowercaseString];
}
- (NSString *)replaceStarInLoction:(NSInteger)loc Lenght:(NSInteger)len {
    NSRange range = NSMakeRange(loc, len);
    NSMutableString *star = [[NSMutableString alloc] init];
    for (int i = 0; i < len; i++) {
        [star appendString:@"*"];
    }
    return [self stringByReplacingCharactersInRange:range withString:star];
}
@end
